<?php 
	$data['menu'] = 'module';
	$data['title'] = '区域管理';
	$data['site_url'] = site_url('manager/area/area/');
	$data['csses'] = array('js/plug/treeTable/css/jquery.treeTable.css');
	$data['jses'] = array('js/plug/treeTable/js/jquery.treeTable.js');
	$this->load->view('manager/header',$data);
?>
<div class="crumbs">当前位置：<a href="#">模块管理</a> &gt; <span class="silver">区域管理</span></div>
<div class="tip tip-b">
    <p class="alert noclose"><i class="icon"></i>重要提醒：<a class="steelBlue" href="#"></a></p>				
</div>
<div class="list-tab">
	<ul>
		<li <?php if($action == 'list') echo 'class="cur"'?>><a href="<?php echo site_url('manager/area/area/index/');?>">区域列表</a></li>
		<li <?php if($action == 'add') echo 'class="cur"'?> title="新增区域"><a href="<?php echo site_url('manager/area/area/add/');?>" title="新增区域">新增区域</a></li>
		<?php if($action == 'edit') 
			echo '<li class="cur" title="编辑区域">编辑区域</li>';
		?>
	</ul>
</div>
<?php if($action == 'list'){?>
<script type="text/javascript">
	$(document).ready(function($) {
	    $("#areaTable").treeTable();
	    // Make visible that a row is clicked
	    $("table#areaTable tbody tr").live('mousedown',function() {
	      $("tr.selected").removeClass("selected"); // Deselect currently selected rows
	      $(this).addClass("selected");
	    });
		/*
	    // Make sure row is selected when span is clicked
	    $("table#dnd-example tbody tr span").mousedown(function() {
	      $($(this).parents("tr")[0]).trigger("mousedown");
	    });
	    */
//	    $('.WinBox').colorbox();
//	    alert($('.tableWrap').width());
	});
</script>
<!-- 
<style>
.tableWrap{padding-top:23px;position:relative;}
.tableInner{height:480px;width:100%;overflow-y:scroll;overflow-x:hidden;}
.tableInner thead tr{position: absolute;left:0px;top:1px;} 
.tableInner tbody{height:22px;}
</style>
<div class="tableWrap">
	<div class="tableInner"> -->
		<table id="areaTable" border="0" cellpadding="0" cellspacing="0">
			<thead>
				<tr>
					<th style="width:auto;">名称</th>
					<th width="100px">排序</th>
					<th width="100px">子类数量</th>
					<th width="200px">操作</th>
				</tr>
			</thead>
			<tbody>
				<?php 
				function areaTree($list) {
					if(isset($list))
						foreach ($list as $item) {
							$isChildren = isset($item['childs']);
							echo '<tr id=node_',$item['id'],' class="',($isChildren?'parent ':''),($item['parentid']!=0?'child-of-node_'.$item['parentid']:''),'">
									<td><input type=checkbox value=',$item['id'],'/><span class=',($isChildren?'folder':'file'),'>',$item['name'],'</span></td>
									<td>',$item['sort'],'</td>
									<td>',$item['sub_num'],'</td>
									<td>
										<a class="iconAdd" href=',site_url('manager/area/area/add/'.$item['id']),' title=添加子类> + </a>
										<a class="iconEdit" href=',site_url('manager/area/area/edit/'.$item['id']),' title=编辑> # </a>',
										($item['sub_num'] == 0?
										'<a class="op_ajax iconDel" href='.site_url('manager/area/area/dodelete/'.$item['id']).' title=删除> x </a>':
										'<a class=iconNull></a>'),
									'</td>
								</tr>';
							if($isChildren){
								areaTree($item['childs']);
							}
						}
				}
				areaTree($list);
				?>
			</tbody>
		</table>
		<!-- 
	</div>
</div> -->
<?php }else if($action == 'add' || $action == 'edit'){
	echo $form;
}?>
<?php $this->load->view('manager/footer');?>